home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_08
/
1008133a
< prev
next >
Wrap
Text File
|
1992-06-07
|
1KB
|
36 lines
#define MAX_STRINGS 100
#define SIZE_STRING 100
#define SIZE_ALL_STRINGS 5000
char *get_string(int index)
{
static char *string[MAX_STRINGS];
static char *string_buffer;
static int initialized;
int size;
int total_size = 0;
int count;
FILE *string_file;
if (!initialized)
{
string_buffer = calloc(SIZE_ALL_STRINGS, 1);
string_file = fopen("string.fil","r");
/* Read the file into string_buffer */
string[0] = string_buffer;
size = 0;
for (count = 0; count < MAX_STRINGS; count++)
{
fgets(string_file, string[count], SIZE_STRING);
size = strlen(string[count]);
string[count][size - 1] = '\0';
size--;
total_size += size;
string[count+1] = string_buffer + total_size;
}
initialized = 1;
}
return string[index];
}